#include <vcl.h>
#pragma hdrstop

#include "uCocheBoutonRouge.h"
#include "EIC.h"
#include "Outils.h"
#pragma package(smart_init)

#pragma resource "*.dfm"



bool __fastcall EICFenetreRouge(const AnsiString &Titre,const AnsiString &Title,const AnsiString &Info,const AnsiString &Question,bool FenetreImprimer)
{
  TdlgDosWarn *Fenetre;
  bool Resultat;
  try
    {
      Resultat = false;
      Fenetre = new TdlgDosWarn(Titre,Title,Info,Question,FenetreImprimer);
      Resultat = (Fenetre->ShowModal() == mrYes);
    }
  catch(...)
    {
    }
  delete Fenetre;
  return Resultat;
}




__fastcall TdlgDosWarn::TdlgDosWarn(const AnsiString &Titre,const AnsiString &Title,const AnsiString &Info,const AnsiString &Question,bool FenetreImprimer): CForm(( TComponent*)NULL)
{
  TRect Rect;
  int Difference;
  ::MessageBeep(MB_ICONEXCLAMATION);
  #ifdef _DEBUG
    if (IS_MACHINE_INFORMATICIEN())
     {
       chkEnableYes->Checked = true;
       btYes->Enabled = true;
     }
  #endif
  Caption = Titre;
  lblTitle->Caption = Title;
  lblInfo->Caption = Info;
  lblQuestion->Caption = Question;
  Rect = lblInfo->ClientRect;
  lblInfo->Height = DrawText(lblInfo->Canvas->Handle,lblInfo->Caption.c_str(),lblInfo->Caption.Length(),(tagRECT *)&Rect,DT_CALCRECT | DT_CENTER | DT_WORDBREAK) + 4;
  Difference = lblInfo->Height - 71;
  if (Difference > 0)
    {
      Height += Difference;
      btYes->Top += Difference;
      btNo->Top += Difference;
      lblQuestion->Top += Difference;
      chkEnableYes->Top += Difference;
    }
  Rect = lblQuestion->ClientRect;
  lblQuestion->Height = DrawText(lblQuestion->Canvas->Handle,lblQuestion->Caption.c_str(),lblQuestion->Caption.Length(),(tagRECT *)&Rect,DT_CALCRECT | DT_CENTER | DT_WORDBREAK) + 4;
  Difference = lblQuestion->Height - 33;
  if (Difference > 0)
    {
      Height += Difference;
      btYes->Top += Difference;
      btNo->Top += Difference;
      chkEnableYes->Top += Difference;
    }
  if(FenetreImprimer)
    {
    chkEnableYes->Visible = false;
    btYes->Visible = false;
    btNo->Visible = false;
    btnImprimer->Visible = true;
    btnOK->Visible = true;
    btnImprimer->Left = btYes->Left;
    btnOK->Left = btYes->Left;
    btnImprimer->Top = btYes->Top;
    btnOK->Top = btNo->Top;
    }
} 




void __fastcall TdlgDosWarn::chkEnableYesClick(TObject *Sender)
{
  btYes->Enabled = chkEnableYes->Checked;
}


void __fastcall TdlgDosWarn::btnImprimerClick(TObject *Sender)
{
this->Print();
}


